Tester - Unit Testing for Php
Its a unit testing library. But phpunit is probably better.
Install
This also requires code-scrawl for development, but Code Scrawl is not yet setup on packagist.
composer require taeluf/tester v0.2-candidate.x-dev
or in your composer.json
{"require":{ "taeluf/tester": "v0.2-candidate.x-dev"}}
or copy+paste this into a bash terminal
pwd="$(pwd)";
command="phptest8"
downloadDir=~/.gitclone
mkdir -p "$downloadDir"
cd "$downloadDir"
git clone https://gitlab.com/taeluf/php/php-tests.git ${command}
echo "alias ${command}=\"${downloadDir}/${command}/code/phptest\"" >> ~/.bashrc
chmod ug+x "${downloadDir}/${command}/code/phptest"
cd "$pwd";
source ~/.bashrc
echo "You can now run \`${command}\`"
Usage
In a terminal, run phptest
or ./vendor/bin/phptest
from your project root. (depending whether you installed via bash or composer)
Example Test class:
<?php
namespace Taeluf\Tester\Test\SubTest;
class Test extends \Taeluf\Tester {
/** called before tests are run */
public function prepare(){}
/** Test methods must prefix with `test` */
public function testAnything(){
$this->compare(true,true);
}
}
Available Assertions
I'll properly document assertions after I write the php grammar for my taeluf/php/lexer
See code/trait/Assertions.php